#!/usr/bin/env python
# chmod a+x calibrator.cfg
PACKAGE = "thermalvis"
import roslib; roslib.load_manifest("dynamic_reconfigure")
import roslib;roslib.load_manifest(PACKAGE)

from dynamic_reconfigure.parameter_generator import *

gen = ParameterGenerator()

# Operation parameters
gen.add("stopCapturing", bool_t, 0, "stopCapturing", False)
gen.add("autoTimeout", double_t, 0, "Time to wait in seconds for new images before attempting calibration", 2.0, 0.0, 60.0)
gen.add("trackingMode", bool_t, 0, "Attempt to track pattern rather than redetect", False)
gen.add("invertPrimary", bool_t, 0, "Primary video source should be inverted (e.g. thermal chessboard)", False)
gen.add("invertSecondary", bool_t, 0, "Secondary video source should be inverted (e.g. thermal chessboard)", False)

# Termination
gen.add("maxFrames", int_t, 0, "Maximum number (if any) of frames before terminating data capture", 0, 0, 15000)
gen.add("maxPatterns", int_t, 0, "Maximum number (if any) of detected patterns before terminating data capture", 0, 0, 15000)
gen.add("maxCandidates", int_t, 0, "Maximum number (if any) of candidates to trial for model formation", 0, 0, 300)
gen.add("maxTests", int_t, 0, "Maximum number (if any) of frames to use to test each candidate", 0, 0, 1500)
gen.add("maxTime", double_t, 0, "Maximum amount of time to spend capturing data before commencing calibration", 0, 0, 600.0)

# Debug options
gen.add("drawGrids", bool_t, 0, "Draw grids on undistorted images", False)
gen.add("generateFigures", bool_t, 0, "Generate some figures for publication", False)
gen.add("verboseMode", bool_t, 0, "Output more information to terminal", False)

# Model parameters
gen.add("alpha", double_t, 0, "Alpha level for undistortion and new cam mat", 0.0, -1.0, 1.0)
gen.add("autoAlpha", bool_t, 0, "Automatically find best alpha level", True)

# Fine control
gen.add("flowThreshold", double_t, 0, "Sensitivity for optical flow algorithm", 0.0001, 0.0000, 1.0000)
gen.add("maxFrac", double_t, 0, "Maximum proportion of minor image dimension that points may drift between frames for tracking", 0.02, 0.00, 1.00)
gen.add("errorThreshold", double_t, 0, "Error threshold for feature exclusion from tracker", 0.0, 0.0, 200.0)
gen.add("maxInterpolationTimegap", double_t, 0, "For unsynchronized extrinsic calibration, maximum time difference between interpolated frame pairs", 0.01, 0.0, 1.0)
gen.add("maxInterpolationMotion", double_t, 0, "For unsynchronized extrinsic calibration, maximum pixel motion between interpolated frame pairs", 5.0, 0.0, 20.0)

# MSER Settings
# primary
gen.add("adjustMSER_primary", bool_t, 0, "adjustMSER_primary", False)
gen.add("delta_primary", int_t, 0, "delta_primary", 8, 0, 100)
gen.add("maxVar_primary", double_t, 0, "maxVar_primary", 0.25, 0.0, 2)
gen.add("minDiv_primary", double_t, 0, "minDiv_primary", 0.2, 0.0, 2)
gen.add("areaThreshold_primary", double_t, 0, "areaThreshold_primary", 1.01, 0.0, 5)
#secondary
gen.add("adjustMSER_secondary", bool_t, 0, "adjustMSER_secondary", False)
gen.add("delta_secondary", int_t, 0, "delta_secondary", 8, 0, 100)
gen.add("maxVar_secondary", double_t, 0, "maxVar_secondary", 0.25, 0.0, 2)
gen.add("minDiv_secondary", double_t, 0, "minDiv_secondary", 0.2, 0.0, 2)
gen.add("areaThreshold_secondary", double_t, 0, "areaThreshold_secondary", 1.01, 0.0, 5)

exit(gen.generate(PACKAGE, "calibrator", "calibrator"))
